package com.itstyle.seckill.common.designPattern.zhongjie;

public class User {
    private String name;
    private ChatRoom chatRoom;

    public User(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void login(ChatRoom chatRoom){
        chatRoom.connect(this);
    }

    public void logout(ChatRoom chatRoom){
        chatRoom.loginOut(this);
    }

    public void sendMsg(ChatRoom chatRoom ,String msg){
        chatRoom.sendMsg(this,msg);
        System.out.print("当前房间：【"+chatRoom.getName()+"】");
    }

    public void Listen(User user, String msg){
        System.out.println("用户【"+user.name+"】对用户【"+name +"】说："+msg);
    }
}
